package jukebox.model.freecomment;

import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;

import jukebox.model.common.CommentVO;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class FreeCommentDAOImpl implements FreeCommentDAO {
	@Resource(name="sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;
	
	/**
	* @method : freeWriteComment
	* @author : 조서영
	* @since : 2014-06-26
	* @param : bvo 
	* @return : void
	* @comment : 자유게시판 댓글 작성
	*/
	@Override
	public void freeWriteComment(CommentVO cvo) {
		sqlSessionTemplate.insert("freeboard.freeWriteComment",cvo);
	}
	
	/**
	* @method : freeFindCommentListByBoardNo
	* @author : 조서영
	* @since : 2014-06-26
	* @param : no-댓글 번호 
	* @return : List<CommentVO>
	* @comment : 자유게시판 댓글 목록 불러오기
	*/
	@Override
	public List<CommentVO> freeFindCommentListByBoardNo(HashMap map) {
		return sqlSessionTemplate.selectList("freeboard.freeFindCommentListByBoardNo",map);
	}

	/**
	* @method : freeDeleteComment
	* @author : 조서영
	* @since : 2014-06-26
	* @param : no-댓글 번호 
	* @return : 
	* @comment : 자유게시판 댓글 지우기
	*/
	@Override
	public void freeDeleteComment(int no) {
		sqlSessionTemplate.delete("freeboard.freeDeleteComment",no);	
	}
	/**
	* @method : freeUpdateComment
	* @author : 조서영
	* @since : 2014-06-26
	* @param : cvo 
	* @return : 
	* @comment : 자유게시판 댓글 수정
	*/
	@Override
	public void freeUpdateComment(CommentVO cvo) {
		sqlSessionTemplate.selectOne("freeboard.freeUpdateComment",cvo);
		
	}

	@Override
	public int freeCommentCount(int no) {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.selectOne("freeboard.freeCommentCount",no);
	}

}
